//
//  XMN_PostsDetailCell.m
//  B段项目
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 谢美娜. All rights reserved.
//

#import "XMN_PostsDetailCell.h"
#import "Header.h"

@implementation XMN_PostsDetailCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _covImageView = [[UIImageView alloc]init];
        [self addSubview:_covImageView];
        
        _titleLabel = [[myContectLabel alloc]init];
        [self addSubview:_titleLabel];
        
        _timeLabel = [[UILabel alloc]init];
        [_timeLabel NightWithType:UIViewColorTypeNormal];
        _timeLabel.font = [UIFont systemFontOfSize:11];
        _timeLabel.textColor = [UIColor lightGrayColor];
        [self addSubview:_timeLabel];
        
        _contentLabel = [[myContectLabel alloc]init];
        _contentLabel.textColor = [UIColor grayColor];
        [self addSubview:_contentLabel];
        
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    _covImageView.frame = CGRectMake(10 * FitWidth, 10 * FitHeight, 40 * FitWidth, 40 * FitHeight);
    _covImageView.layer.masksToBounds = YES;
    _covImageView.layer.cornerRadius = 20;
    _titleLabel.frame = CGRectMake(_covImageView.frame.origin.x + _covImageView.frame.size.width + 5 * FitWidth, _covImageView.frame.origin.y + 2 * FitHeight, 200 * FitWidth, 20 * FitHeight);
    _timeLabel.frame = CGRectMake(_titleLabel.frame.origin.x, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 5 * FitHeight, 200 * FitWidth, 15 * FitHeight);
    _contentLabel.frame = CGRectMake(_covImageView.frame.origin.x, _covImageView.frame.origin.y + _covImageView.frame.size.height + 10 * FitHeight, self.contentView.frame.size.width - 20 * FitWidth, 20 * FitHeight);
}

-(void)setPostsList:(XMN_PostsList *)postsList{
    [_covImageView sd_setImageWithURL:[NSURL URLWithString:[postsList.userinfo objectForKey:@"icon"]]];
    [_covImageView sd_setImageWithURL:[NSURL URLWithString:[postsList.userinfo objectForKey:@"icon"]] placeholderImage:[UIImage imageNamed:@"SHD_Cov"]];
    _contentLabel.text = postsList.content;
    _timeLabel.text = postsList.addtime_f;
    _titleLabel.text = [postsList.userinfo objectForKey:@"uname"];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
